class Router
  constructor:->
    $('section').hide() #隐藏掉所有section
    page '*', (state)=>
      @go state.path #跳转到指定的路径。这是默认行为
      return
    page({hashbang:true})
  go:(url)->
    #路由跳转函数
    console.log "跳转到#{url}"
    sections = $('section')
    section = sections.filter("[data-route='#{url}']")
    if (section.length)
      sections.hide(250)
      section.show(250)
    else
      console.log "#{url} 并不存在哦。"
    return
  register:->
    return page


thin.define "$router",[],->

  return new Router
